Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.25 XMR BOUNTY] - meile_node_uptime.py - Limit requests to find remote_url #2

Merged
merged 2 commits into from
Jul 12, 2023
Merged

[0.25 XMR BOUNTY] - meile_node_uptime.py - Limit requests to find remote_url #2

merged 2 commits into from
Jul 12, 2023

Conversation

trinitystake
Copy link
Contributor

No description provided.

@MathNodes
Copy link
Owner

MathNodes commented Jul 11, 2023

HI - Thanks for the pull request. I tested it and there were some errors with it and some things not needed. I would have went a little different route with this, but I like your attempt. Please refactor your get_remote_url_of_node() code to look like the following and I will merge the pull request and pay the bounty:

def get_remote_url_of_node(self, db, NodeData):
        NodeRemoteURL = {'address' : [], 'url' : []}
        
        c = db.cursor()
        
        for n in NodeData:
            address = n['node_address']
            endpoint = APIURL + '/nodes/' + address
                
            # Retrieve remote_url from the table for nodes that have it stored
            query = f"SELECT remote_url FROM node_uptime WHERE node_address = '{address}';"
            c.execute(query)
            result = c.fetchone()

            if result['remote_url'] == '':        
                endpoint = APIURL + '/nodes/' + address
                remote_url = result['remote_url']
                print(f"Getting remote_url of: {address}", end=":")
                
                try:
                    r = requests.get(endpoint)
                    remote_url = r.json()['result']['node']['remote_url']
                except Exception as e:
                    print(str(e))
                    continue
                print(f"{remote_url}")
            else:
                remote_url = result['remote_url']
                
            NodeRemoteURL['address'].append(n['node_address'])
            NodeRemoteURL['url'].append(remote_url)
        
        return NodeRemoteURL

@trinitystake
Copy link
Contributor Author

Done! Thanks, need to remove some rust here and there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants